package com.example.qxfw.common.util;

import com.example.qxfw.common.entity.qx.MsgMediumSmallScale;

/************************************
 *
 * @author : HuangDeYin Jolly
 * @since : JDK 11
 * @Date : 2023/8/11  星期五   12:48
 * @description : 此类用来
 ***************************************/
public class StringUtil {

    public static String extractAlphanumeric(String input) {
        int index = -1;
        for (int i = 0; i < input.length(); i++) {
            if (Character.isLetterOrDigit(input.charAt(i))) {
                index = i;
                break;
            }
        }
        if (index != -1) {
            return input.substring(index);
        }
        return null;
    }


    /************************
     * @Author : HuangDeYin Jolly
     * @Description :此方法用用来将-65535或者99999变为null
     * @return T :
     ************************/

    public static <T> T toNull(T in) {
        if (in == null || in.toString().isEmpty() || in.toString().equals("-65535") || in.toString().equals("-65535.0") || in.toString().equals("999999")) {
            return null;
        }
        return in;
    }

    public static String chineseToEnglish(String column){
        String type = "";
        if (column.equals("温度")){
            type = "drybulbtemp" ;
        }
        if (column.equals("湿度")){
            type = "relhumidity";
        }
        if (column.equals("露点温度")){
            type = "dewtemp";
        }
        if (column.equals("风向")){
            type = "winddirect";
        }
        if (column.equals("风速")){
            type = "windvelocity";
        }
        if (column.equals("气压")){
            type = "stationpress";
        }
        if (column.equals("蒸散量ET")){
            type = "evaporation";
        }
        if (column.equals("雨量")){
            type = "rain";
        }
        if (column.equals("最大风速")){
            type = "maxwindv";
        }
        if (column.equals("最高温度")){
            type = "maxtemp";
        }
        if (column.equals("最低温度")){
            type = "mintemp";
        }
        return type;

    }

    public static Object getData(MsgMediumSmallScale msgMediumSmallScale,String column){
        if (column.equals("温度")){
            return msgMediumSmallScale.getDrybulbtemp();
        }
        if (column.equals("湿度")){
            return msgMediumSmallScale.getRelhumidity();
        }
        if (column.equals("露点温度")){
            return msgMediumSmallScale.getDewtemp();
        }
        if (column.equals("风向")){
            return msgMediumSmallScale.getWinddirect();
        }
        if (column.equals("风速")){
            return msgMediumSmallScale.getWindvelocity();
        }
        if (column.equals("气压")){
            return msgMediumSmallScale.getStationpress();
        }
        if (column.equals("蒸散量ET")){
            return msgMediumSmallScale.getEvaporation();
        }
        if (column.equals("雨量")){
            return msgMediumSmallScale.getRain();
        }
        if (column.equals("最大风速")){
            return msgMediumSmallScale.getMaxwindv();
        }
        if (column.equals("最高温度")){
            return msgMediumSmallScale.getMaxtemp();
        }
        if (column.equals("最低温度")){
            return msgMediumSmallScale.getMintemp();
        }
        return "无";
    }


}
